public class Disk {  
    private boolean[][] blocks;  
    private int freeBlockCount;  
  
    public Disk(int size) {  
        blocks = new boolean[size][size];  
        freeBlockCount = size * size;  
    }  
  
    public boolean isFree(int x, int y) {  
        return blocks[x][y];  
    }  
  
    public void allocate(int x, int y) {  
        if (freeBlockCount == 0) {  
            System.out.println("No free blocks available.");  
            return;  
        }  
        blocks[x][y] = true;  
        freeBlockCount--;  
    }  
  
    public void deallocate(int x, int y) {  
        if (!blocks[x][y]) {  
            System.out.println("Block is not allocated.");  
            return;  
        }  
        blocks[x][y] = false;  
        freeBlockCount++;  
    }  
}